﻿using MediatR;
using SheepStorage.API.Application.Command.SheepMomPergnantCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.DTO.Output;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.SheepMomPergnantHandler
{
    public class SheepMomPergnantShowCommandHandler : IRequestHandler<SheepMomPergnantShowCommand, Results<List<SheepMomPergnantDto>>>
    {

        private readonly ISheepMomPergnantService sheepMomPergnantService;
        public SheepMomPergnantShowCommandHandler(ISheepMomPergnantService sheepMomPergnantService)
        {
            this.sheepMomPergnantService = sheepMomPergnantService;
        }
        public async Task<Results<List<SheepMomPergnantDto>>> Handle(SheepMomPergnantShowCommand request, CancellationToken cancellationToken)
        {
            var entity = await sheepMomPergnantService.GetSheepMomPergnant(request.endTime, request.startTime, request.OverBit, request.MomPergnantPrincipal, request.MomPergnantResult,  request.MomPergnantCount);
            if(entity == null)
            {
                return Results<List<SheepMomPergnantDto>>.FailResult();
            }
                return Results<List<SheepMomPergnantDto>>.DataResult(entity);

        }
    }
}
